﻿@model Bricks.Site.Models.EnvironmentalView

@{
    ViewBag.Title = "编辑通报";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}

@*引入uEditor*@
<script type="text/javascript" charset="utf-8" src="/Res/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/Res/ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="/Res/ueditor/lang/zh-cn/zh-cn.js"></script>
<link rel="stylesheet" type="text/css" href="/Res/ueditor/themes/default/css/ueditor.css" />

<script>
    $(function () {
        $.MiniUEditorInit($("#hID").val(), "SafetyManagement/Environmental/Content", "content", 500, 150);  //迷你加载
    });

    var isCorrective = $("#hIsCorrective").val();  //是否需要整改
    if (isCorrective.length > 0) {
        $("#isCorrective").attr("checked", true);  //整改则勾选
        document.getElementById("correctiveSection").readOnly = false;  //非只读
        $('#chooseCorrectiveSection').linkbutton({
            plain: true,
            iconCls: 'icon-bell',
            disabled: false  //按钮可用
        });
    }
    else {
        $("#isCorrective").attr("checked", false);
        $("#correctiveSection").val("");  //清空整改标段显示值
        $("#contractIDs").val("");  //清空整改标段保存值
        document.getElementById("correctiveSection").readOnly = true;  //只读
        $('#chooseCorrectiveSection').linkbutton({
            plain: true,
            iconCls: 'icon-bell',
            disabled: true  //按钮不可用
        });
    }

    //是否需要整改触发事件：决定整改标段是否可用
    $("#isCorrective").change(function () {
        var checked = $("#isCorrective").attr("checked");
        if (checked != null) {
            document.getElementById("correctiveSection").readOnly = false;  //非只读
            $('#chooseCorrectiveSection').linkbutton('enable');  //按钮可用
            $("#hIsCorrective").val("true");
            //$.EasyuiSlide("true");
        }
        else {
            $("#correctiveSection").val("");  //清空整改标段显示值
            $("#contractIDs").val("");  //清空整改标段保存值
            document.getElementById("correctiveSection").readOnly = true;  //只读
            $('#chooseCorrectiveSection').linkbutton('disable');  //按钮禁用
            //$.EasyuiSlide("false");
        }
    })

    var Edit = {
        //选择标段
        ChooseCorrectiveSection: function () {
            //Url：/BidInfo/ChooseBid
            //$.EasyuiSlide("ChooseCorrectiveSection");
            $("#tempContractIDs").val($("#contractIDs").val());  //弹出的时候，将contractIDs赋值给tempContractIDs

            //Edit.ChooseMutual("选择标段", "/BidInfo/ChooseBid", true);
            Edit.ChooseMutual("选择合同", "/ContractInfo/ChooseContract");
        },

        //选择标段弹出框
        ChooseMutual: function (title, href) {
            $.ModelDialog({
                title: title, href: href, width: 718,
                handler: function () {
                    $.ModelForm({
                        validate: true, button: $(this),
                        id: "#environmental-model",
                        url: "/ContractInfo/ChooseContractPost",
                        success: function (result) {
                            //Environmental.Reload();
                            var tempContractIDs = $("#tempContractIDs").val();
                            $("#contractIDs").val(tempContractIDs);
                            var contractIDs = $("#contractIDs").val();
                            //$.EasyuiSlide(contractIDs);

                            $.post("/ContractInfo/GetFullContractNameByID?ids=" + contractIDs, function (res) {
                                //res = JSON.parse(res);
                                //$("#correctiveSection").val(res.AppendData);
                                $("#correctiveSection").val(res);
                                //$.EasyuiSlide($("#correctiveSection").val());
                            });

                        }
                    });
                },
                onLoad: function () {
                    //Environmental.FormInit(isAdd);
                }
            });
        }

        //SetCorrectiveEnabled: function () {
        //    debugger;
        //    var checked = $("#IsCorrective").val();
        //    if (checked == "true") {
        //        //$("#IsCorrective").val("false");
        //        document.getElementById("correctiveSection").readOnly = false;  //非只读
        //        $('#chooseCorrectiveSection').linkbutton('enable');  //按钮可用
        //    }
        //    else {
        //        $("#IsCorrective").val("true");
        //        $("#correctiveSection").val("");  //清空整改标段显示值
        //        $("#contractIDs").val("");  //清空整改标段保存值
        //        document.getElementById("correctiveSection").readOnly = true;  //只读
        //        $('#chooseCorrectiveSection').linkbutton('disable');  //按钮禁用
        //    }
        //}
    }
</script>

<div class="frombox datagrid-body" style="padding-bottom: 5px;">
    <form id="environmental-model" method="post">
        <table class="datagrid-btable" border="0" cellspacing="0" cellpadding="0">
            <tr class="datagrid-row">
                <td class="th">
                    <div class="datagrid-cell">通报名称</div>
                </td>
                <td class="td" colspan="7">
                    <div class="datagrid-cell">
                        <input name="CircularName" class="easyui-validatebox" data-options="required:true" style="width:456px;" value="@Model.CircularName" />
                    </div>
                </td>
            </tr>
            <tr class="datagrid-row">
                <td class="th">
                    <div class="datagrid-cell">需要整改</div>
                </td>
                <td class="td">
                    <div class="datagrid-cell">
                        @*<input id="isCorrective" name="IsCorrective" value="@Model.IsCorrective" />*@
                        @*@Html.CheckBoxFor(m => m.IsCorrective)*@
                        @*<input type="checkbox" name="IsCorrective" value="@Model.IsCorrective" />*@

                        @*<input class="check-box" data-val="true" data-val-required="是否整改 字段是必需的。" id="IsCorrective" name="IsCorrective" type="checkbox" value="@Model.IsCorrective" />
                            <input name="IsCorrective" type="hidden" value="@Model.IsCorrective" />*@

                        <input id="isCorrective" type="checkbox" value="true" />
                    </div>
                </td>
                <td class="rth">
                    <div class="datagrid-cell">发布时间</div>
                </td>
                <td class="td">
                    <div class="datagrid-cell">
                        <input name="PublishTime" class="easyui-textbox" value="@Model.PublishTime" style="background:#eeeeee;" readonly />
                    </div>
                </td>
            </tr>
            <tr class="datagrid-row">
                <td class="th">
                    <div class="datagrid-cell">发布单位</div>
                </td>
                <td class="td">
                    <div class="datagrid-cell">
                        @*<input id="publishOrg" name="PublishOrg" class="easyui-textbox" value="@Model.PublishOrg" style="background:#eeeeee;" readonly />*@
                        <input id="publishOrgID" name="PublishOrgID" class="easyui-textbox" value="@Model.PublishOrgID" />
                    </div>
                </td>
                <td class="rth">
                    <div class="datagrid-cell">发布人</div>
                </td>
                <td class="td">
                    <div class="datagrid-cell">
                        <input name="PublishUser" class="easyui-textbox" style="background:#eeeeee;" value="@Model.PublishUser" readonly />
                    </div>
                </td>
            </tr>
            <tr class="datagrid-row">
                <td class="th">
                    <div class="datagrid-cell">整改标段</div>
                </td>
                <td class="td" colspan="7">
                    <div class="datagrid-cell">
                        <input id="correctiveSection" name="CorrectiveSection" data-options="required:false" style="width:393px;" value="@Model.CorrectiveSection" />
                        @*<a id="chooseCorrectiveSection" href='javascript:void(0)' class='easyui-linkbutton' onclick='Edit.ChooseCorrectiveSection()' data-options='plain:true,iconCls:"icon-bell"'>选择</a>*@
                        <a id="chooseCorrectiveSection" href="javascript:void(0)" onclick="Edit.ChooseCorrectiveSection()">选择</a>
                    </div>
                </td>
            </tr>
            <tr class="datagrid-row">
                <td class="th">
                    <div class="datagrid-cell">通报内容</div>
                </td>
                <td class="td" colspan="7">
                    <div class="datagrid-cell">
                        <textarea id="content" name="Content" cols="57" rows="5">@Model.Content</textarea>
                    </div>
                </td>
            </tr>
        </table>
        <input id="hID" name="ID" type="hidden" value="@Model.ID" />
        @*<input name="PublishOrgID" type="hidden" value="@Model.PublishOrgID" />*@
        <input id="hPublishUserID" name="PublishUserID" type="hidden" value="@Model.PublishUserID" />
        <input id="tempContractIDs" type="hidden" />
        <input id="contractIDs" name="CorrectiveSectionIDs" type="hidden" value="@Model.CorrectiveSectionIDs" />
        <input name="IsDeleted" type="hidden" value="@Model.IsDeleted" />
        <input name="AddDate" type="hidden" value="@Model.AddDate" />
        <input id="hIsCorrective" name="IsCorrective" type="hidden" value="@Model.IsCorrective" />
    </form>
</div>
